<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>月兑现率统计</title>
    <link href="../../Scripts/jquery-easyui/themes/bootstrap/easyui.css" rel="stylesheet" />
    <script src="../../Scripts/jquery-easyui/jquery.min.js"></script>
    <script src="../../Scripts/jquery-easyui/jquery.easyui.min.js"></script>
    <script src="../../Scripts/jquery-easyui/locale/easyui-lang-zh_CN.js"></script>
    <link href="../../Content/themes/icon.css" rel="stylesheet" />
    <link href="../../Content/themes/table.css" rel="stylesheet" />
    <link href="../../Content/formstyles.css" rel="stylesheet" />
    <script src="../../Content/js/common.js?v=1"></script> 
    <link href="../../Content/themes/table.css" rel="stylesheet" />   
<style>
.datagrid-header-row td{background-color:#1AB1D8;color:#fff;text-align:center}
</style>
</head>
<body>
    <div id="ui_user_layout" class="easyui-layout" data-options="fit:true,border:false">

        <div data-options="region:'center',border:false">
			<p style="font-size: 20px;padding-left: 300px;">生产任务月兑现率统计</p>
           <table id="dg_main" style="margin:10px"></table> 
            <br>
            <p>数据说明：</p>
            <p>生产任务考核时间，（1）有对应销售订单的任务单及其子单以计划交货日期作为考核时间；（2）无对应销售订单的任务单及其子单以排产计划完工日期作为考核日期；</p>
            <p>计划兑现率=（制造部按计划完成任务数/事业部下达生产任务数）*100%</p>
            <p>考核计划兑现率=（(制造部按计划完成任务数-制造部申请免考核数)/(制造完成数-制造部申请免考核数)）*100%</p>
            <p>兑现率=（制造完成数/事业部下达生产任务数）*100%</p>
         </div>

        <div data-options="region:'south',border:false">
            <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-edit'" onclick="javascript:editDisCheck()">制造部申请免考核</a> 
        </div>
    </div>

    <div id="dlg" class="easyui-dialog" style="width:500px" data-options="closed:true,modal:true,border:'thin',buttons:[{
			text:'申请免考核数量',
			iconCls:'icon-ok',
			handler:function(){saveEntry()}
		},{
			text:'取消',
			iconCls:'icon-cancel',
			handler:function(){$('#dlg').dialog('close')}
		}]">
        <form id="fm" method="post" novalidate style="margin:0;padding:20px 50px">
            <div style="margin-bottom:2px">
                <input type="text" class="easyui-textbox" id="m1" data-options="width:120, label:'1月',labelPosition:'before',labelWidth:40,labelAlign:'right',readonly:false" />
                <input type="text" class="easyui-textbox" id="m2" data-options="width:120, label:'2月',labelPosition:'before',labelWidth:40,labelAlign:'right',readonly:false" />
                <input type="text" class="easyui-textbox" id="m3" data-options="width:120, label:'3月',labelPosition:'before',labelWidth:40,labelAlign:'right',readonly:false" />
                  </div>
            <div style="margin-bottom:2px">
                 <input type="text" class="easyui-textbox" id="m4" data-options="width:120, label:'4月',labelPosition:'before',labelWidth:40,labelAlign:'right',readonly:false" />
                <input type="text" class="easyui-textbox" id="m5" data-options="width:120, label:'5月',labelPosition:'before',labelWidth:40,labelAlign:'right',readonly:false" />
                <input type="text" class="easyui-textbox" id="m6" data-options="width:120, label:'6月',labelPosition:'before',labelWidth:40,labelAlign:'right',readonly:false" />
            </div>
            <div style="margin-bottom:2px">
                <input type="text" class="easyui-textbox" id="m7" data-options="width:120, label:'7月',labelPosition:'before',labelWidth:40,labelAlign:'right',readonly:false" />
                <input type="text" class="easyui-textbox" id="m8" data-options="width:120, label:'8月',labelPosition:'before',labelWidth:40,labelAlign:'right',readonly:false" />
                <input type="text" class="easyui-textbox" id="m9" data-options="width:120, label:'9月',labelPosition:'before',labelWidth:40,labelAlign:'right',readonly:false" />
                  </div>  
            <div style="margin-bottom:2px">
                    <input type="text" class="easyui-textbox" id="m10" data-options="width:120, label:'10月',labelPosition:'before',labelWidth:40,labelAlign:'right',readonly:false" />
                <input type="text" class="easyui-textbox" id="m11" data-options="width:120, label:'11月',labelPosition:'before',labelWidth:40,labelAlign:'right',readonly:false" />
                <input type="text" class="easyui-textbox" id="m12" data-options="width:120, label:'12月',labelPosition:'before',labelWidth:40,labelAlign:'right',readonly:false" />
            </div>            
            <div style="margin-bottom:10px">
                <input name="remark" id="remark" class="easyui-textbox" label="备注:" style="width:100%">
            </div>
        </form>
    </div>
  <script type="text/javascript">

 
        $(function () { 
        
            $("#dg_main").datagrid({       //初始化datagrid
                     url: "/Rpt/GetRptCommon?&r=" + Math.random(),
					striped: true, rownumbers: false, pagination: false, pageSize: 20, singleSelect: true,
					width:800, 
					queryParams: {
					    "RptName": "MonthMOFinishRate",
						 "year": 2019,
					},
                // idField: 'MonthMOFinishRate',
                // sort: 'UpdateTime',
                // order: 'desc',
                //pageList: [20, 40, 60, 80, 100],
					frozenColumns: [[ ]],
					columns: columns,
					// toolbar: toolbar.length == 0 ? null : toolbar,
					onSelect: function (rowIndex, rowData) {
					},
					onLoadSuccess: function (data) {
						
					}
				});
                        

        })

  var  columns=   [[
					{ width: 80, title: '', field: 'month', align: 'right', sortable: false },
                     { width: 100, title: '事业部下达<br>生产任务数', field: 'orderBillCount', align: 'center', sortable: false },
                          { width: 100, title: '制造部按计划<br>完成任务数', field: 'onTimeFinishCount', align: 'center', hidden: false },
                          { width: 100, title: '制造完成数', field: 'allFinishCount', align: 'center', },
						   { width: 100, title: '制造部申请<br>免考核数', field: 'disCheckCount', align: 'center', },
						    {
						        width: 100, title: '计划兑现率', field: 'jhdxl', align: 'center', formatter: getPercent
							   },
							 {
							     width: 100, title: '考核计划<br>兑现率', field: 'khjhdxl', align: 'center', formatter: getPercent
							 },
							  { width: 100, title: '兑现率', field: 'dxl', align: 'center', formatter: getPercent },
                          
  ]];

  function editDisCheck() {
      $('#dlg').dialog('open').dialog('center').dialog('setTitle', '申请免考核数量');
      var rows=  $("#dg_main").datagrid('getRows'); 
      for (var i = 1; i < 13; i++) { 
          $('#m' + i).textbox('setValue', rows[i - 1].disCheckCount);//赋值
      } 
  }
  function saveEntry() {
      //if (!$("#fm").form('validate')) {//表单校验
      //    $.show_alert("错误", "表单校验未通过！请注意录入数据格式");
      //    return;
      //} else {
      //    if (lock) { return; } else { lock = true; }
      //}
     // $.show_alert("开始", "测试开始");
      $.ajax({
          url: "/Produce/updateDisCheckCount",
          type: "post",
          data: {
              "yearID": 2019, 
              'm1': $('#m1').textbox('getValue'),
              'm2': $('#m2').textbox('getValue'),
              'm3': $('#m3').textbox('getValue'),
              'm4': $('#m4').textbox('getValue'),
              'm5': $('#m5').textbox('getValue'),
              'm6': $('#m6').textbox('getValue'),
              'm7': $('#m7').textbox('getValue'),
              'm8': $('#m8').textbox('getValue'),
              'm9': $('#m9').textbox('getValue'),
              'm10': $('#m10').textbox('getValue'),
              'm11': $('#m11').textbox('getValue'),
              'm12': $('#m12').textbox('getValue'),
              'remark': $('#remark').textbox('getValue'),
          },
          dataType: 'json',//html\script\text\xml\json
          beforeSend: function () { },//
          complete: function () { lock = false; },
          timeout: 3000,
          success: function (data) {
              if (data.success) {
                  $.show_alert("成功", "填报成功！"); 
                  $('#dlg').dialog('close');
                  $("#dg_main").datagrid("reload");
              } else {
                  $.show_alert("提示", data.msg);
              }
          },
          error: function (XMLHttpRequest, textStatus, errorThrown) {
              if (textStatus == "timeout") {
                  $.show_alert("提示", "请求超时，请刷新当前页重试！");
              }
              else {
                  $.show_alert("错误", textStatus + "：" + errorThrown);
              }
          },

      });
  }
	</script>

</body>
</html>
